package com.ics.atable.chat.model.dto;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
@Data
public class SynonymsExtract {

    @Schema(description = "同义词")
    private List<List<String>> synonyms;

    // 无参构造函数
    public SynonymsExtract() {}

    @JsonCreator
    public SynonymsExtract(@JsonProperty("synonyms") List<List<String>> synonyms) {
        this.synonyms = synonyms;
    }

    @JsonCreator
    public static SynonymsExtract fromJsonString(String json) {
        try {
            log.info("SynonymsExtract_json: {}", json);
            ObjectMapper mapper = new ObjectMapper();
            return mapper.readValue(json, SynonymsExtract.class);
        } catch (Exception e) {
            throw new IllegalArgumentException("Failed to parse JSON: " + json, e);
        }
    }
}
